zephyr_library_named(opus_codec)
zephyr_library_sources(
    A2NLSF.c
    CNG.c
    HP_variable_cutoff.c
    LPC_analysis_filter.c
    LPC_fit.c
    LPC_inv_pred_gain.c
    LP_variable_cutoff.c
    LTP_analysis_filter_FIX.c
    LTP_scale_ctrl_FIX.c
    NLSF2A.c
    NLSF_VQ.c
    NLSF_VQ_weights_laroia.c
    NLSF_decode.c
    NLSF_del_dec_quant.c
    NLSF_encode.c
    NLSF_stabilize.c
    NLSF_unpack.c
    NSQ.c
    NSQ_del_dec.c
    PLC.c
    VAD.c
    VQ_WMat_EC.c
    ana_filt_bank_1.c
    analysis.c
    apply_sine_window_FIX.c
    autocorr_FIX.c
    bands.c
    biquad_alt.c
    burg_modified_FIX.c
    bwexpander.c
    bwexpander_32.c
    celt.c
    celt_decoder.c
    celt_encoder.c
    celt_lpc.c
    arm/celt_pitch_xcorr_arm_gcc.s
    check_control_input.c
    code_signs.c
    control_SNR.c
    control_audio_bandwidth.c
    control_codec.c
    corrMatrix_FIX.c
    cwrs.c
    debug.c
    dec_API.c
    decode_core.c
    decode_frame.c
    decode_indices.c
    decode_parameters.c
    decode_pitch.c
    decode_pulses.c
    decoder_set_fs.c
    enc_API.c
    encode_frame_FIX.c
    encode_indices.c
    encode_pulses.c
    entcode.c
    entdec.c
    entenc.c
    find_LPC_FIX.c
    find_LTP_FIX.c
    find_pitch_lags_FIX.c
    find_pred_coefs_FIX.c
    gain_quant.c
    init_decoder.c
    init_encoder.c
    inner_prod_aligned.c
    interpolate.c
    k2a_FIX.c
    k2a_Q16_FIX.c
    kiss_fft.c
    laplace.c
    lin2log.c
    log2lin.c
    mathops.c
    mdct.c
    mlp.c
    mlp_data.c
    modes.c
    noise_shape_analysis_FIX.c
    opus.c
    opus_decoder.c
    opus_encoder.c
    opus_multistream.c
    opus_multistream_decoder.c
    opus_multistream_encoder.c
    pitch.c
    pitch_analysis_core_FIX.c
    pitch_est_tables.c
    process_NLSFs.c
    process_gains_FIX.c
    quant_LTP_gains.c
    quant_bands.c
    rate.c
    regularize_correlations_FIX.c
    repacketizer.c
    resampler.c
    resampler_down2.c
    resampler_down2_3.c
    resampler_private_AR2.c
    resampler_private_IIR_FIR.c
    resampler_private_down_FIR.c
    resampler_private_up2_HQ.c
    resampler_rom.c
    residual_energy16_FIX.c
    residual_energy_FIX.c
    schur64_FIX.c
    schur_FIX.c
    shell_coder.c
    sigm_Q15.c
    sort.c
    stereo_LR_to_MS.c
    stereo_MS_to_LR.c
    stereo_decode_pred.c
    stereo_encode_pred.c
    stereo_find_predictor.c
    stereo_quant_pred.c
    sum_sqr_shift.c
    table_LSF_cos.c
    tables_LTP.c
    tables_NLSF_CB_NB_MB.c
    tables_NLSF_CB_WB.c
    tables_gain.c
    tables_other.c
    tables_pitch_lag.c
    tables_pulses_per_block.c
    vector_ops_FIX.c
    vq.c
    warped_autocorrelation_FIX.c
    arm/celt_pitch_xcorr_arm_gcc.s
)

zephyr_library_include_directories( ./ arm )

# Private preprocessor defines
target_compile_definitions(opus_codec PRIVATE
    ARM_MATH_CM4
    OPUS_ARM_ASM
    OPUS_ARM_INLINE_ASM
    OPUS_ARM_INLINE_EDSP
    OPUS_ARM_INLINE_MEDIA
    OPUS_ARM_MAY_HAVE_EDSP
    OPUS_ARM_PRESUME_EDSP
    OPUS_BUILD
    USE_ALLOCA
    FIXED_POINT
    DISABLE_FLOAT_API
    HAVE_CONFIG_H
    HAVE_ALLOCA_H
    HAVE_LRINT
    HAVE_LRINTF
)

# Private compile options
target_compile_options(opus_codec PRIVATE
    -fsingle-precision-constant
    # The library has a ton of warnings around array writes
    -Wno-stringop-overread
)
